/******************************************************************************\
*  Animeshell 1.0 Multimedia manager                                           *
*  Copyright (C) 2006-2007 Rémy Guillemette <shaikadzari@gmail.com>            *
*                                                                              *
*  This program is free software; you can redistribute it and/or modify        *
*  it under the terms of the GNU General Public License version 2 only as      *
*  published by the Free Software Foundation.                                  *
*                                                                              *
*  This program is distributed in the hope that it will be useful,             *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
*  GNU General Public License for more details.                                *
*                                                                              *
*  You should have received a copy of the GNU General Public License           *
*  along with this program; if not, write to the                               *
*  Free Software Foundation, Inc.,                                             *
*  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                   *
\******************************************************************************/

#ifndef FRMANIMESHELLIMPL_H
#define FRMANIMESHELLIMPL_H


#include <QTreeWidget>
#include <QTreeWidgetItem>
//
#include "ui_frmAnimeshell.h"
#include "mysqliteclass.h"
#include "imgcontrol.h"
#include "animeshellrc.h"
//
enum enuprofile
{
	folder = 0, filter, browser, websearch, editor, player
};
	
/*!
	\class MainWindowImpl
	\brief Main window class
*/
class MainWindowImpl : public QMainWindow, public Ui::MainWindowImpl
{
Q_OBJECT
public:
	MainWindowImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
	bool initialload();
	bool initialdatabase();
	
	/*! animetable(int pInd)
		\brief Access QList<animeclass> m_AnimeList
		\param[in] pLine Position in the QList
		\return animeclass object
	*/
	animeclass AnimeTable(int pInd);
	
	/*! animetable(int pInd)
		\brief Access QList<animeclass> m_AnimeList
		\param[in] pLine Position in the QList
		\return int position in m_AnimeList
	*/
	int AnimeTablePosition(int pInd);
	
private:
	mysqliteclass* m_MySqliteClass;
	animeshellrc* m_AnimeShellRc;
	QStringList m_CurrentProfile;
	QList<QTreeWidgetItem *> m_Items;
	bool m_ActionNewEntry;
	QString m_AddImageName;
	
	QList<animeclass> m_AnimeList;
	QList<animeclass> m_SearchList;
	
	
private slots:
	/////////////////////////////////////////////////////////
	// Buttons
	/////////////////////////////////////////////////////////
	
	/*! btnSearch_Clicked()
		\brief Slot called when btnSearch is clicked
		
		SearchInAnimeList will be called with an 
		animeclass object made from entry.
	*/
	void btnSearch_Clicked();
	
	
	/*! btnEditImg_Clicked()
		\brief Slot called when btnEditImg is clicked
		
		imgcontrol::startprocess() will be called with default image editor
		and the name of the image to edit.
	*/
	void btnEditImg_Clicked();
	
	/*! btnAddImg_Clicked()
		\brief Slot called when btnAddImg is clicked
		
		imgcontrol::copyimg() will be called to copy the chaosen image
		in the default animeshell folder.
	*/
	void btnAddImg_Clicked();
	
	/*! btnSaveEntry_Clicked()
		\brief Slot called when btnSaveEntry is clicked
	*/
	void btnSaveEntry_Clicked();
	
	/*! btnEraseEntry_Clicked()
		\brief Slot called when btnEraseEntry is clicked
	*/
	void btnEraseEntry_Clicked();
	
	/*! btnSupImage_Clicked()
		\brief Slot called when btnSupImage is clicked
	*/
	void btnSupImage_Clicked();
	
	/////////////////////////////////////////////////////////
	// Main Menu
	/////////////////////////////////////////////////////////
	void actionRecharger_Triggered();
	void actionRecherche_interne_Triggered();
	void actionRecherche_externe_Triggered();
	void actionGoReference_Triggered();
	void actionPropos_Triggered();
	void actionAide_Triggered();
	void actionProposQT_Triggered();
	void actionStartPlayer_Triggered();
	void actionQuitter_Triggered();
	void actionNouvelleEntre_Triggered();
	void actionModifierEntre_Triggered();
	
	/*! TreeWidgetOnClickEvent()
	*/
	void TreeWidgetOnClickEvent();
	
	
	/*! SearchInAnimeList(animeclass pSearch, bool pStrict)
	    \brief Search an animeclass object in the QList
	    \param[in] pSearch An animeshell object with all data to search
		\param[in] pStrict Specify to use the strict search option
		\return QList<animeclass> with all found result
	*/
	QList<animeclass> SearchInAnimeList(animeclass pSearch, bool pStrict);
	
	
	/*! SearchString(QString pSearch, QString pEntry, bool pStrict)
		\brief Search an utf8 string
		
		If pStrict is true, this function will compare the two upper
		string. If pStrict is false, this function will search for a
		substring in pEntry.
		
		\param[in] pSearch The name to search
		\param[in] pEntry The string to compare
		\param[in] pStrict Specify to use the strict search option
		\return True if the string is found
	*/
	bool SearchString(QString pSearch, QString pEntry, bool pStrict);
	
	/*! LoadImageFile(QString pImgName)
		\brief Load an image
		\param[in] pImgName the name of the image to load
	*/
	void LoadImageFile(QString pImgName);
	
	/*! AddObjectToList(int pNoSeq)
		\brief Add animeclass object to QList membre
		
		If pNoSeq is null, a new object is append in the list. If pNoSeq
		is not null, the corresponding animeclass object in the list is
		modified.
		
		\param[in] pA animeclass object to add or save
		\param[in] pNewEntry new or modified entry
		\return True if append is successful
	*/
	bool AddObjectToList(animeclass pA, bool pNewEntry);
	
	/*! PopulateTreeView()
		\brief Load entry in the treeview	
	*/
	void PopulateTreeView();
	
	/*! PopulateTreeView( QString pFilter )
		\brief Load a search list in the treewidget
		\param[in] pFilter Filter to use in the treewidget
	*/
	void PopulateTreeView( int pFilter );
	
	/*! cboFilterChanged()
		\brief Slot called when selection change in cboFilter
	*/
	void cboFilterChanged();
	
	/*! cboProfilChanged()
	    \brief Slot called when selection change in cboProfil
	*/
	void cboProfilChanged();
};
#endif




